package es.udc.emarketapp.emarket.model.purchase.purchaseFacade.actions;


import es.udc.emarketapp.emarket.model.orderLine.dao.SQLOrderLineDAO;
import es.udc.emarketapp.emarket.model.orderLine.dao.SQLOrderLineDAOFactory;

import java.sql.Connection;

import es.udc.fbellas.j2ee.util.exceptions.InternalErrorException;
import es.udc.fbellas.j2ee.util.exceptions.ModelException;
import es.udc.fbellas.j2ee.util.sql.NonTransactionalPlainAction;

public class FindOrderLineByIdAction implements NonTransactionalPlainAction {

	private Long idOrderLine;
	private Long idOrder;
	private Long idPurchase;

	public FindOrderLineByIdAction(Long idOrderLine, 
			Long idOrder, Long idPurchase) {
		this.idPurchase = idPurchase;
		this.idOrder = idOrder;
		this.idOrderLine = idOrderLine;
	}

	public Object execute(Connection connection) throws InternalErrorException,
			ModelException {

		SQLOrderLineDAO orderLineDAO = SQLOrderLineDAOFactory.getDAO();

		return orderLineDAO.findById(connection, idOrderLine, 
				idOrder, idPurchase);

	}
}
